<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>查找重复元素</title>
</head>

<body>
  <script>
    function duplicates(arr) {
      var temp = [];
      arr.forEach(function (elem) {
        if (arr.indexOf(elem) != arr.lastIndexOf(elem) && temp.indexOf(elem) == -1) {
          temp.push(elem);
        }
      });


      return temp;
    }
  </script>
</body>

</html>